package org.papervision3d.core.proto
{
    import org.papervision3d.core.geom.*;
    import flash.geom.*;
    import org.papervision3d.objects.DisplayObject3D;

    public class TraverseCallback
    {
        protected var clip:Rectangle;

        public function init(scene:SceneObject3D, camera:CameraObject3D, clip:Rectangle):void
        {
            this.clip = clip;
        }

        protected function inclip(triangle:DrawTriangle):Boolean
        {
           var halfwidth:Number = triangle.width / 2;
            var halfheight:Number = triangle.height / 2;
            var cx:Number = triangle.centerx;
            var cy:Number = triangle.centery;

            if (cx - halfwidth < clip.right && cx + halfwidth > clip.left)
            {
                if (cy + halfheight < clip.top)
                    return false;
                if (cy - halfheight > clip.bottom)
                    return false;
                    
                return true;
            }
            
           //return(  clip.contains( triangle.v0.x, triangle.v0.y ) || clip.contains( triangle.v1.x, triangle.v1.y )|| clip.contains( triangle.v2.x, triangle.v2.y ) )

            return false;
        }

        protected function inclippoint(x:Number, y:Number):Boolean
        {
            return (x >= clip.left) && (x <= clip.right) && (y >= clip.top) && (y <= clip.bottom);
        }

        public function enter(node:DisplayObject3D):Boolean
        {
            return node.visible;
        }

        public function leave(node:DisplayObject3D):void
        {
        }

        public function face(face:Face3D, object:Mesh3D):void
        {
        }

        public function list():Array
        {
            return null;
        }
    }
}

